// 将数值限定在start和end之间
export function between(value: number, start: number | undefined, end: number | undefined): number {
  if (start !== undefined)
    value = value < start ? start : value

  if (end !== undefined)
    value = value > end ? end : value

  if (start && end && start > end)
    throw new Error('开始start不能大于结束end')

  return value
}